import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:untitled/pages/Getx_project/TestA.dart';


class GetxDemo extends StatefulWidget {
  const GetxDemo({Key? key}) : super(key: key);

  @override
  State<GetxDemo> createState() => _GetxDemoState();
}

class _GetxDemoState extends State<GetxDemo> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          ElevatedButton(
              onPressed: (){
              // 动态 静态的方式
              Get.to(new TestAPage());

              },
              child: Text("getx 动态路由打开A页面"),
          ),
          ElevatedButton(
              onPressed: (){
              // 动态 静态的方式
              Get.toNamed("/testa");

              },
              child: Text("getx 静态路由打开A页面"),
          ),
          ElevatedButton(
              onPressed: (){
              Get.off(new TestAPage());
              Navigator.of(context).pushReplacement(
                new MaterialPageRoute(builder: (BuildContext context){
                  return new TestAPage();
                })
              );

              },
              child: Text("getx 替换当前的页面"),
          ),
          ElevatedButton(
              onPressed: (){
              Get.offAll(new TestAPage());
              Navigator.of(context).pushAndRemoveUntil(
                new MaterialPageRoute(builder: (BuildContext context){
                  return new TestAPage();
                }),
                (Route route) => false,
              );

              },
              child: Text("getx 打开新的页面，并关闭之前所有的页面"),
          ),
        ],
      )
    );
    
  }
}